package org.novelhibernate.test;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

import org.novelhibernate.exception.NovelhibernateException;
import org.novelhibernate.support.logging.DefaultExceptionHandler;
import org.novelhibernate.support.logging.GenericLogFactory;
import org.novelhibernate.support.logging.LogHandler;
import org.novelhibernate.support.logging.NativeLogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


import junit.framework.TestCase;

public class LogTesting extends TestCase {

	public void testCase(){
		
		//ApplicationContext contex=new ClassPathXmlApplicationContext("/configurations/spring/applicationContext*.xml"); 
		//GenericManager e = (GenericManager)contex.getBean("enMaterialManager");
		
		
		//e.testFind();
		
		NativeLogFactory f = NativeLogFactory.getInstance();
		
		ILogClass l = null;
		try {
			f.setDefaultExceptionHandler("test", new test());
			Proxy p1 = (Proxy)f.produceLogPointBase(LogClass.class,true);
	
			Proxy p2 = (Proxy)f.produceLogPointBase((ILogClass)p1, LogClass.class);
		
			
			System.out.print("return ****"+((ILogClass)p2).print("22","22",1,"222","111")+"\n");
		} catch (Throwable e) {
			// TODO Auto-generated catch block
		e.printStackTrace();
			//System.out.print(e.getClass() == NullPointerException.class);
		} 
	
		
	}
	
	private class test implements DefaultExceptionHandler{

		@Override
		public Object doExceptionHandling(Object target, Method method,
				Object[] args, Throwable t) throws NovelhibernateException,
				Throwable {
			if(t instanceof NullPointerException){
			System.out.print("do default handling!!!!!!!!!!!");
			return 100;
			}
			else throw new NovelhibernateException();
		}

		
		
	}
}
